package com.group3.hospital.mapper;

import com.group3.hospital.bean.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author 秀秀
 */
public interface UserMapper {

    @Insert("insert into user (username,user_password,user_tel) values (#{username},#{userPassword},#{userTel})")
    void insertUser(@Param("username") String username,@Param("userPassword") String userPassword,@Param("userTel") Long userTel) throws Exception;

    @Select("select username,user_tel,user_password,user_id from user where username = #{username} and user_tel = #{userTel} and user_password = #{userPassword}")
    User queryUser(@Param("username") String username,@Param("userTel") Long userTel,@Param("userPassword") String userPassword) throws Exception;


    @Update("update user set username = #{username},user_tel = #{userTel},user_password = #{userPassword} where user_id = #{userId}")
    void update(User user) throws Exception;

    @Select("select user_id,username,user_tel from user")
    List<User> queryAll() throws Exception;

    @Delete("delete from user where user_id = #{userId}")
    void deleteById(Integer userId)throws Exception;

    @Select("select * from user where username = #{username}")
    User queryByName(String username) throws Exception;

    @Select("select * from user where user_id = #{userId}")
    User queryById(Integer userId);
}
